Library/Library.Test/TestStreamCache.cs
C# | Copy Code |
---|---|
Stream stream; using (StreamCache cache = new StreamCache(new SharedMemoryStream(), 1)) { using (stream = cache.Open()) { Assert.IsTrue(stream.CanRead); Assert.IsTrue(stream.CanWrite); Assert.IsTrue(stream.CanSeek); } using (stream = ((IFactory<Stream>)cache).Create()) { Assert.IsTrue(stream.CanRead); Assert.IsTrue(stream.CanWrite); Assert.IsTrue(stream.CanSeek); } using (stream = cache.Open(FileAccess.Read)) { Assert.IsTrue(stream.CanRead); Assert.IsFalse(stream.CanWrite); Assert.IsTrue(stream.CanSeek); } using (stream = cache.Open(FileAccess.Write)) { Assert.IsFalse(stream.CanRead); Assert.IsTrue(stream.CanWrite); Assert.IsTrue(stream.CanSeek); } } |
VB.NET | Copy Code |
---|---|
Dim stream As Stream Using cache As New StreamCache(New SharedMemoryStream(), 1) Using stream = cache.Open() Assert.IsTrue(stream.CanRead) Assert.IsTrue(stream.CanWrite) Assert.IsTrue(stream.CanSeek) End Using Using stream = (DirectCast(cache, IFactory(Of Stream))).Create() Assert.IsTrue(stream.CanRead) Assert.IsTrue(stream.CanWrite) Assert.IsTrue(stream.CanSeek) End Using Using stream = cache.Open(FileAccess.Read) Assert.IsTrue(stream.CanRead) Assert.IsFalse(stream.CanWrite) Assert.IsTrue(stream.CanSeek) End Using Using stream = cache.Open(FileAccess.Write) Assert.IsFalse(stream.CanRead) Assert.IsTrue(stream.CanWrite) Assert.IsTrue(stream.CanSeek) End Using End Using |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
IFactory<T> InterfaceIFactory<T> Members
Used By
TestCollectionTestCollection
TestCollection
TestCollection
TestCollection
TestCollection
TestCollection
TestCollection
TestDictionary
TestDictionary
TestDictionary
Stream StreamCache.Open(FileAccess)
ILockStrategy LockCounterFactory.Create()